package cn.m3a1.creditsystem.service;

import cn.m3a1.creditsystem.bean.User;
import cn.m3a1.creditsystem.bean.UserExample;
import cn.m3a1.creditsystem.dao.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author wyj
 * @date 2020/2/19
 * @time 下午5:14
 */
@Service
public class LoginService {
    @Autowired
    UserMapper userMapper;
    /**
     * 验证登录的用户名和密码是否匹配
     * @return  true代表用户名密码正确
     */
    public List<User> getCheckLogin(User user){

        UserExample userExample=new UserExample();
        UserExample.Criteria criteria = userExample.createCriteria();
        criteria.andUsernameEqualTo(user.getUsername().trim());
        criteria.andPasswordEqualTo(user.getPassword().trim());
        List<User> users = userMapper.selectByExample(userExample);

        return  users;
    }
    public  Boolean setpassword(User user){

        int i = userMapper.updateByPrimaryKey(user);
        return i==1;
    }
}
